﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Demo
{
    public partial class TreeView : Form
    {
        public TreeView()
        {
            InitializeComponent();
        }

        private void TreeView_Load(object sender, EventArgs e)
        {
            TreeNode node = new TreeNode("Chức vụ");

            node.Nodes.Add("Nhân viên");
            node.Nodes.Add("Trưởng phòng");

            TreeNode node1 = new TreeNode("Quản lý");
            node1.Nodes.Add("Quản lý 1");
            node1.Nodes.Add("Quản lý 2");
            node.Nodes.Add(node1);


            demoTreeView.Nodes.Add(node);

            node = new TreeNode("Bộ phận");
            node.Nodes.Add("Kinh doanh");
            node.Nodes.Add("Kế toán");
            node.Nodes.Add("Marketing");
            demoTreeView.Nodes.Add(node);

            plusMinusCheck.Checked = demoTreeView.ShowPlusMinus;
            rootLineCheck.Checked = demoTreeView.ShowRootLines;
        }

        private void showItemButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Selected Item : " + demoTreeView.SelectedNode.Text);
        }

        private void plusMinusCheck_CheckedChanged(object sender, EventArgs e)
        {
            demoTreeView.ShowPlusMinus = plusMinusCheck.Checked;
        }

        private void rootLineCheck_CheckedChanged(object sender, EventArgs e)
        {
            demoTreeView.ShowRootLines = rootLineCheck.Checked;
        }
    }
}